/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package ServerGUI;
import java.net.Socket;

import java.net.InetAddress;
import Server.ClientList;

/**
 *
 * @author cypek
 */
public class ServerGUIController {

    private Socket socket;
    private String targetHost;
    private InetAddress destAddress;
    private int viaPort;
    private ClientList ClientLists;

    private int currentDirection;
    private int currentFloor;
    private boolean isServerGUIRunning = false;


    public ServerGUIController(String targetHost, int viaPort) {
        this.targetHost = targetHost;
        this.viaPort = viaPort;
        initSocket();
    }


    /**
     * Get the value of currentFloor
     *
     * @return the value of currentFloor
     */
    public int getCurrentFloor() {
        return currentFloor;
    }

    /**
     * Set the value of currentFloor
     *
     * @param currentFloor new value of currentFloor
     */
    public void setCurrentFloor(int currentFloor) {
        this.currentFloor = currentFloor;
    }

    /**
     * Get the value of currentDirection
     *
     * @return the value of currentDirection
     */
    public int getCurrentDirection() {
        return currentDirection;
    }

    /**
     * Set the value of currentDirection
     *
     * @param currentDirection new value of currentDirection
     */
    public void setCurrentDirection(int currentDirection) {
        this.currentDirection = currentDirection;
    }

    /**
     * Get the value of ClientLists
     *
     * @return the value of ClientLists
     */
    public ClientList getClientLists() {
        return ClientLists;
    }

    /**
     * Set the value of ClientLists
     *
     * @param ClientLists new value of ClientLists
     */
    public void setClientLists(ClientList ClientLists) {
        this.ClientLists = ClientLists;
    }



    /**
     * Get the value of isServerGUIRunning
     *
     * @return the value of isServerGUIRunning
     */
    public boolean isIsServerGUIRunning() {
        return isServerGUIRunning;
    }

    /**
     * Set the value of isServerGUIRunning
     *
     * @param isServerGUIRunning new value of isServerGUIRunning
     */
    public void setIsServerGUIRunning(boolean isServerGUIRunning) {
        this.isServerGUIRunning = isServerGUIRunning;
    }

        public Socket getSocket() {
        return socket;
    }

    public void setSocket(Socket socket) {
        this.socket = socket;
    }

    public String getTargetHost() {
        return targetHost;
    }

    public void setTargetHost(String targetHost) {
        this.targetHost = targetHost;
    }

    public int getViaPort() {
        return viaPort;
    }

    public void setViaPort(int viaPort) {
        this.viaPort = viaPort;
    }

    public void initSocket()
    {

        try{
            System.out.print("Trying to connect....");
            destAddress = InetAddress.getByName(this.getTargetHost()); // Destination address
            int destPort = this.getViaPort();              // Destination port
            this.socket = new Socket(destAddress, destPort);
            this.setIsServerGUIRunning(true);


            System.out.println("done.");
            
        }
        catch (Exception ex)
        {
            System.out.println("failed.");
        }
    }

}
